# -*- coding:utf-8 -*-
import os
class ReadTestFile:
    def __init__(self):
        pass

    def readfile(self):
        self.rtf = open("extScript\\UserNo.txt", "r")
        userno = self.rtf.read()
        self.rtf.close()
        self.writefile(userno)
        return userno

    def writefile(self, struserno=None):
        self.wtf = open("extScript\\UserNo.txt", "w")
        self.wtf.write(str(int(struserno) + 1))
        self.wtf.close()
        # self.rtf.flush()

    def writedist(self, bdc_num=None):

        wtf = open("extendScript\\dist.txt", "w")

        wtf.write(bdc_num)
        wtf.flush()
        wtf.close()

    def writestart(self, startno=None):

        wtf = open("inputdata\\start.txt", "w")
        wtf.write(startno)
        wtf.flush()
        wtf.close()

    def writerun(self, startno=None):
        wtf = open("inputdata\\runstatus.txt", "w")
        wtf.write(startno)
        wtf.flush()
        wtf.close()

    def writestop(self, startno=None):
        wtf = open("inputdata\\stopstatus.txt", "w")
        wtf.write(startno)
        wtf.flush()
        wtf.close()

    def writeflnum(self, startno=None):
        wtf = open("inputdata\\flnum.txt", "w")
        wtf.write(startno)
        wtf.flush()
        wtf.close()

    def writedbnum(self, startno=None):
        wtf = open("inputdata\\dbnum.txt", "w")
        wtf.write(startno)
        wtf.flush()
        wtf.close()

    def getflnum(self):
        rtfd = open("inputdata\\flnum.txt", "r")
        dist = rtfd.read()
        rtfd.close()
        return dist

    def getdbnum(self):
        rtfd = open("inputdata\\dbnum.txt", "r")
        dist = rtfd.read()
        rtfd.close()
        return dist

    def getdist(self):
        rtfd = open("extendScript\\dist.txt", "r")
        dist = rtfd.read()
        rtfd.close()
        return dist

    def get_danganno(self):
        rtfd = open("extendScript\\DangAnNO.txt", "r")
        danganno = rtfd.read()
        rtfd.close()
        return danganno

    def getstart(self):
        rtfd = open("..\\inputdata\\start.txt", "r")
        startnum = rtfd.read()
        rtfd.close()
        return startnum

    def getrun(self):
        rtfd = open("inputdata\\runstatus.txt", "r")
        startnum = rtfd.read()
        rtfd.close()
        return startnum

    def getstop(self):
        rtfd = open("inputdata\\stopstatus.txt", "r")
        startnum = rtfd.read()
        rtfd.close()
        return startnum

    def get_mysql_excel(self):
        rtfd = open("inputdata\\Excel_or_Mysql.txt", "rb")
        result = rtfd.readlines()
        rtfd.close()
        return result[0]


class ReadTextFile_DangAnNO:
    def __init__(self):
        rtfd = open("extendScript\\DangAnNO.txt", "r")
        danganno = rtfd.read()
        rtfd.close()
        return danganno


if __name__ == '__main__':
    rtf = ReadTestFile()
    # rtf.writefile(rtf.readfile())
    # print(rtf.readfile())
    # rtf.writefile()
    #print(int(rtf.readfile())+1)
    aa = rtf.get_mysql_excel()
    print aa
